<!--
 * @Descripttion: your project
 * @version: 1.0
 * @Author: hongweixun
 * @Date: 2022-07-14 15:28:18
 * @LastEditors: hongweixun
 * @LastEditTime: 2022-09-08 13:00:52
-->
<template>
  <dv-scroll-board
    :config="tableConfig"
    ref="scrollBoard"
  />
</template>
<script>
import { mapState } from 'vuex'
export default {
  data () {
    return {
      innerHeight: window.innerHeight,
      tableConfig: {
        header: [
          '<span style="color:#01C7FF;">姓名</span>',
          '<span style="color:#01C7FF;">班级</span>',
          '<span style="color:#01C7FF;">楼栋</span>',
          '<span style="color:#01C7FF;">房号</span>',
          '<span style="color:#01C7FF;">床号</span>',
          '<span style="color:#01C7FF;">评分</span>',
          '<span style="color:#01C7FF;">状态</span>'
        ],
        data: [],
        align: ['center', 'center', 'center', 'center', 'center'],
        headerBGC: '',
        rowNum: 3,
        headerHeight: 40,
        oddRowBGC: 'transparent',
        evenRowBGC: 'transparent'
      }
    }
  },
  computed: {
    ...mapState(['dormitScore', 'dormitBool'])
  },
  watch: {
    dormitScore: {
      handler: function (newValue, oldValue) {
        if (newValue !== oldValue && oldValue.length !== 0) {
          this.$refs.scrollBoard.updateRows(this.dormitScore)
        }
      }
    }
  },
  methods: {},
  mounted () {
    this.$nextTick(() => {
      setTimeout(() => {
        if (this.dormitScore) {
          if (!this.dormitBool) {
            const params = {
              header: [
                '<span style="color:#01C7FF;">姓名</span>',
                '<span style="color:#01C7FF;">班级</span>',
                '<span style="color:#01C7FF;">楼栋</span>',
                '<span style="color:#01C7FF;">房号</span>',
                '<span style="color:#01C7FF;">床号</span>',
                '<span style="color:#01C7FF;">评分</span>',
                '<span style="color:#01C7FF;">状态</span>'
              ],
              data: this.dormitScore,
              align: ['center', 'center', 'center', 'center', 'center'],
              headerBGC: '',
              rowNum: 3,
              headerHeight: 40,
              oddRowBGC: 'transparent',
              evenRowBGC: 'transparent'
            }
            this.tableConfig = params
          } else {
            // this.$refs.scrollBoard.updateRows(this.dormitScore)
          }
        }
      }, 500)
    })
  }
}
</script>
